package com.bysc.cmsservice.controller;

import com.bysc.cmsservice.caller.AiCaller;
import com.bysc.cmsservice.entity.dto.AiDto;
import com.bysc.cmsservice.factory.AiCallerFactory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/cmsservice/cms-ai")
@Api(tags = "ai接口")
public class AiController {
    @Autowired
    private AiCallerFactory aiCallerFactory;

    @PostMapping("/getReply")
    @ApiOperation("根据message数组获取回复")
    public void getReply(@ApiParam(name = "aiDto", value = "请求参数", required = true)@RequestBody AiDto aiDto,
                         HttpServletRequest request, HttpServletResponse userResponse) throws Exception
    {
        AiCaller caller = aiCallerFactory.getAiCaller(aiDto.getModel());
        caller.init();
        caller.getReply(aiDto, request,userResponse);
    }
}
